<html>
<script>
function* idMaker() {
    var index = 0;
    while (index < 3) 
       yield index++;
}

var gen = idMaker();

var result = gen.next();
debugger;
console.log(gen.next().value); // 0
console.log(gen.next().value); // 1
console.log(gen.next().value); // 2
console.log(gen.next().value); // undefined// ...

</script>
</html>